package com.code.day17;

import java.util.ArrayList;
import java.util.function.Consumer;
import java.util.stream.Stream;

public class Demo03Stream {
    public static void main(String[] args) {
//        Stream<String> stream = Stream.of("哪吒传奇", "小鲤鱼历险记", "虹猫蓝兔七侠传", "飞天小女警", "猫眼三姐妹");
        //匿名内部类形式
//        stream.forEach(new Consumer<String>() {
//            @Override
//            public void accept(String s) {
//                System.out.println(s);
//            }
//        });

//        //Lambda表达式
//        stream.forEach(s -> System.out.println(s));
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);

        Stream<Integer> stream = list.stream();
        stream.filter(s -> s>=2).forEach(s-> System.out.println(s));
    }
}
